package com.shui_shui;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class MainMenuActivity extends Activity implements OnTouchListener{
	
	private ImageView mb1;	
	private ImageView mb2;	
	private ImageView mb3;	
	private ImageView mb4;
	
	private Intent newActivity;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);        
		setContentView(R.layout.mainmenu);        
		
        // Main Menu Image        
		mb1 = (ImageView) findViewById(R.id.mb1);        
		mb2 = (ImageView) findViewById(R.id.mb2);        
		mb3 = (ImageView) findViewById(R.id.mb3);        
		mb4 = (ImageView) findViewById(R.id.mb4);    
		
		//  Set Even OnTouch Main         
		mb1.setOnTouchListener(this);        
		mb2.setOnTouchListener(this);        
		mb3.setOnTouchListener(this);        
		mb4.setOnTouchListener(this);
    }

	@SuppressWarnings("deprecation")
	public boolean onTouch(View v, MotionEvent event) {
		switch (v.getId()) {        
		case R.id.mb1:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				mb1.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				mb1.setAlpha(255);  
				newActivity = new Intent(MainMenuActivity.this,CompassHomeActivity.class);
				startActivity(newActivity);	
				break;            
			default:                
				break;            
			}            
			break;        
		case R.id.mb2:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				mb2.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				mb2.setAlpha(255);
				newActivity = new Intent(MainMenuActivity.this,CompassActivity.class);
				startActivity(newActivity);	
				break;            
			default:                
				break;            
			}            
			break;        
		case R.id.mb3:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				mb3.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				mb3.setAlpha(255);   
				newActivity = new Intent(MainMenuActivity.this,BirthdayActivity.class);
				startActivity(newActivity);	
				break;            
			default:                
				break;            
			}            
			break;        
		case R.id.mb4:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				mb4.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				mb4.setAlpha(255);            
				newActivity = new Intent(MainMenuActivity.this,SubMenuActivity.class);
				startActivity(newActivity);	
				break;            
			default:                
				break;            
			}            
			break;
		}        
		return true;
	}
	
    @Override
    public void onBackPressed() 
    {
    	new AlertDialog.Builder(this)
        .setIcon(android.R.drawable.ic_dialog_alert)
        .setTitle("Exit")
        .setMessage("Are you sure you want to exit?")
        .setPositiveButton("Yes", new DialogInterface.OnClickListener()
        {
        	public void onClick(DialogInterface dialog, int which) {
        		finish();
        	}

        })
        .setNegativeButton("No", null)
        .show();
    	
    }
}
